from common import *
from mig.csp2mig.client import Taggedvalue


def MiG_InOrderOutFunc(in0,out0):
	results = {}
	next_tag = 0
	while True:
		while results.has_key(next_tag):
			out0(results[next_tag])
			del results[next_tag]
			next_tag += 1
		# read a new result from a MiG proc
		tv_in = in0()
		results[tv_in.tag] = tv_in.value

